import { AsyncComponentLoader, defineAsyncComponent } from 'vue'
// 导入异步组件加载器
const components = import.meta.glob('./**/*vue')
// 导入组件
export default {
  install(app: any) {
    // 批量注册组件
    for (const [key, value] of Object.entries(components)) {
      const name = key.split('/')[1]
      // 注册组件
      app.component(name, defineAsyncComponent(value as AsyncComponentLoader))
    }
  }
}
